package com.example.config;

import com.dangdang.ddframe.job.lite.api.JobScheduler;
import com.example.job.ElasticJobDemo;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author YJC
 * @version V1.0
 * @description: 作业统一配置
 * @date 2020-11-10 15:13
 */
@Configuration
public class JobConfigurations extends BasicJobConfig {
    //============基于API配置方式的job============
    @Bean
    @ConfigurationProperties(prefix = "elasticJobDemo")
    JobConfigProperties elasticJobDemoConfig() {
        return new JobConfigProperties();
    }

    @Bean(initMethod = "init")
    public JobScheduler elasticJobDemoScheduler(
            final ElasticJobDemo elasticJobDemo,
            JobConfigProperties elasticJobDemoConfig) {
        return buildSpringJobScheduler(elasticJobDemo, elasticJobDemoConfig);
    }

    //其他任务配置
}
